package com.vs.meepet.network.ext

import com.vs.meepet.network.ParamsHelper
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import okhttp3.RequestBody
import retrofit2.Call

inline fun <reified T> Call<T>.asFlow(): Flow<T> {
    return flow {
        emit(execute().body() ?: throw NullPointerException("body is null"))
    }
}

fun Map<String, Any?>.toRequestBody(): RequestBody {
    return ParamsHelper.getBodyJson(this)
}